package finalproject;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;

public class Map extends JFrame implements ActionListener {
    
    MapGUI mapPanel = new MapGUI();
    boolean occupied = false;
    JButton refreshButton;
    
    Map() {
        refreshButton = new JButton("End Turn");
        refreshButton.addActionListener(this);
        //set layout, visible, close operation, size
        this.setLayout(new BorderLayout());
        this.add(mapPanel, BorderLayout.CENTER);
        //this.add(refreshButton, BorderLayout.SOUTH);
        //this.setResizable(false);
        this.setSize(896, 404);
        this.setVisible(true);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        while (true) {
            pause();
            mapPanel.repaint();
            mapPanel.requestFocus();
            if (mapPanel.victory == true) {
                System.exit(0);
            }
        }
    }
    
    private void pause() {
        try {
            Thread.sleep(10);
        } catch (Exception e) {
            System.out.println(e);
        }
    }
    
    @Override
    public void actionPerformed(ActionEvent ae) {
        mapPanel.repaint();
        mapPanel.revalidate();
    }
}
